var form = layui.form;
layer = parent.layer === undefined ? layui.layer : top.layer,
    $ = layui.jquery;
layui.table.render({
    elem: '#linkList',
    url : '/logInfoController/selectlog',
    page : true,
    cellMinWidth : 95,
    method: 'post',
    request: {
        pageName: 'page' //页码的参数名称，默认：page
        ,limitName: 'limit' //每页数据量的参数名，默认：limit
    },
    parseData: function(res){ //res 即为原始返回的数据
        console.log(res.data.totalRec);
        return {
            "code": res.code, //解析接口状态
            "msg": res.msg, //解析提示文本
            "count": res.data.totalRec, //解析数据长度
            "data": res.data.recList //解析数据列表
        };
    },
    limit : 5,
    limits : [5,10,15,20],
    id : "linkListTab",
    cols :[[
        {type:'numbers'}
        ,{field:'userName', title:'操作人', unresize: false}
        ,{field:'url', title:'访问路径',unresize: false}
        ,{field:'operStyle', title:'操作方式',unresize: false,align:'center',templet:function(d){
                if(d.operStyle.toUpperCase() == "GET"){
                    return '<span style="color:blue">'+d.operStyle.toUpperCase()+'</span>'
                }else{
                    return '<span style="color:red">'+d.operStyle.toUpperCase()+'</span>'
                }
        }}
        ,{field:'modleName', title:'模块名称',unresize: true}
        ,{field:'methodName', title:'方法名称',unresize: true,align:'center',templet:function(d){
                if(d.methodName==="查看"){
                    return '<span class="layui-btn layui-btn-green layui-btn-xs">'+d.methodName+'</span>'
                }else{
                    return '<span class="layui-btn layui-btn-danger layui-btn-xs">'+d.methodName+'</span>'
                }
        }}
        ,{field:'ip', title:'访问IP',unresize:true}
        ,{field:'opTime', title:'操作时间',unresize: true}
        ,{field:'dataId', title:'数据ID',unresize: true}
    ]]
});
layui.laydate.render({
    elem: '#beginningAndEndingTime'
    ,type: 'datetime'
    ,range: '~'
});
$('#searchTransport').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
});
var active ={
    reload: function(){
        var beginningAndEndingTime = $('#beginningAndEndingTime');

        //执行重载
        layui.table.reload('linkListTab', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            ,where: {
                beginningAndEndingTime: beginningAndEndingTime.val()
            }
        }, 'data');
    }
};